n, m = map(int, input().split())
p = list(map(int, input().split()))
max_e, min_e = max(p), min(p)
max_num = [0] * (n + 1)
# 最大值i在最大值得到
for i in range(1, n + 1):
    max_num[i] = max([max_num[i], max_e - i, i - min_e])
for i in range(1, n + 1):
    print(max_num[i], end=' ')
